<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>BMI测试</h1>
<form action="">
    <input type="text" name="h" placeholder="身高(米)">
    <input type="text" name="w" placeholder="体重(公斤)">
    <input type="button" value="测试" @click="test()">
    <h1>测试结果:{{info}}</h1>
</form>
<!--引入vue和axios-->
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"form",
        data:{
            info:""
        },
        methods:{
          test : function (){
              //发出异步请求
              let data = new FormData(document.querySelector("form"))
              axios.post("/bmi",data).then(function (response){
                  //把服务器返回的数据直接显示到页面中
                  v.info = response.data;
              })
          }
        }
    });
</script>
</body>
</html>